function fuzzyProvider() {
    $.ajax({
        url: "/provider/fuzzyQueryProvider",
        data: {"condition":$("#scText").val()},
        type: "GET",
        success: function (htmlText) {
            $("#providerSpace").html(htmlText)
        }
    })
}

function providerDetails(id) {
    layer.open({
        type:2,
        title: '查看',
        maxmin: true,
        skin: 'layui-layer-lan',
        shadeClose: true,
        area : ['400px' , '350px'],
        content:'/provider/providerDetails?id='+id,
        end: function () {
            location.reload()
        }
    })
}

function providerUpdate(id) {
    layer.open({
        type:2,
        title: '修改供应商',
        maxmin: true,
        skin: 'layui-layer-lan',
        shadeClose: true,
        area : ['600px' , '450px'],
        content:'/provider/updateProvider'+'?id='+id,
        end: function () {
            location.reload()
        }
    })
}

function addProvider() {
    layer.open({
        type:2,
        title: '添加供应商',
        maxmin: true,
        skin: 'layui-layer-lan',
        shadeClose: true,
        area : ['600px' , '450px'],
        content:'/provider/addProvider',
        end: function () {
            location.reload()
        }
    })
}

function deleteProvider(id){
    layer.confirm('确定删除吗', {icon: 3, title:'提示'}, function(index){
        $.post({
            url:"/provider/deleteProvider",
            data:{"id":id},
            success:function (data) {
                var num = data.code==200 ? 1 : 2;
                layer.msg(data.msg,{icon:num,shade:0.3,offset: '40%',time:2000,content:"正在删除"});
                setTimeout(function(){
                    location.reload();
                },1000);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                if (jqXHR.status == 403){
                    layer.confirm('权限不足', {icon: 2, title:'提示'})
                } else {
                    layer.confirm('发生错误', {icon: 2, title:'提示'})
                }
            }
        })
    })
}